package D240424;

import java.util.Random;
import java.util.Scanner;

// 该方法有bug，暂时停止编辑

public class RpsIndependent {
    public static void main(String[] args) {
        String[] status = new String[]{"Rock", "Paper", "Scissors"};
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您想玩几次？");
        int times = scanner.nextInt();
        for (int j = 0; j < times; j++) {
            System.out.println("请输入你的选择：（rock，paper，scissors）");
            String player = scanner.nextLine();
            int playerNumber = 0;
            boolean areEqual;
            int i;
            for (i = 0; i < status.length; i++) {
                areEqual = player.equalsIgnoreCase(status[i]);
                if (areEqual) {
                    playerNumber = i;
                    break;
                } else if (i == 3) {
                    System.out.println("请输入正确选项！");
                    System.exit(0);
                }
            }
            System.out.println("你的选择是：" + status[playerNumber]);

            Random random = new Random();
            int randomInt = random.nextInt(3);
            System.out.println("电脑出的是：" + status[randomInt]);

            if (playerNumber == randomInt) {
                System.out.println("平局！");
            } else if (playerNumber < randomInt && playerNumber != 0) {
                System.out.println("你输了！");
            } else if (playerNumber == 0) {
                if (randomInt == 1) {
                    System.out.println("你输了！");
                } else {
                    System.out.println("你赢了！");
                }
            } else if (playerNumber > randomInt && randomInt != 0) {
                System.out.println("你赢了！");
            } else if (randomInt != 0) {
                if (playerNumber == 2) {
                    System.out.println("你输了！");
                } else {
                    System.out.println("你赢了！");
                }
            }
        }
    }
}
